from django.urls import path
from . import views

urlpatterns = [
    path('', views.home, name='home'),  # 这是默认页面路径
    path('register/', views.register, name='register'),  # 注册页面
    path('login/', views.login_view, name='login'),  # 登录页面
    path('admin/', views.admin_dashboard, name='admin_dashboard'),  # 管理员仪表盘
    path('planter/', views.planter_dashboard, name='planter_dashboard'),  # 种植员仪表盘
    path('inspector/', views.inspector_dashboard, name='inspector_dashboard'),  # 检测员仪表盘



        # 作物相关的视图
    path('crop/', views.crop_list, name='crop_list'),  # 显示作物列表
    path('crop/add/', views.add_crop, name='add_crop'),  # 添加作物
   

    # 日志相关的视图
    path('log/', views.log_list, name='log_list'),  # 显示日志列表，传递crop_id
    path('log/add/', views.add_log, name='add_log'),  # 添加日志

    path('get_crops/', views.get_crops, name='get_crops'),
    path('get_logs/', views.get_logs, name='get_logs'), 

    path('get_pests/', views.get_pests, name='get_pests'),
    path('get_inspections/', views.get_inspections, name='get_inspections'),
    path('add_pest/', views.add_pest, name='add_pest'),
    path('add_inspection/', views.add_inspection, name='add_inspection'),

    path('get_pest/<int:id>/', views.get_pest, name='get_pest'),
    path('update_pest/<int:id>/', views.update_pest, name='update_pest'),
    path('delete_pest/<int:id>/', views.delete_pest, name='delete_pest'),

    path('get_inspection/<int:id>/', views.get_inspection, name='get_inspection'),
    path('update_inspection/<int:id>/', views.update_inspection, name='update_inspection'),
    path('delete_inspection/<int:id>/', views.delete_inspection, name='delete_inspection'),

    path('get_crops/', views.get_crops, name='get_crops'),
    path('add_crop/', views.add_crop, name='add_crop'),
    path('update_crop/<int:id>/', views.update_crop, name='update_crop'),
    path('delete_crop/<int:id>/', views.delete_crop, name='delete_crop'),
    path('get_crop/<int:id>/', views.get_crop, name='get_crop'),  # 获取单个作物

    # 日志相关
    path('get_logs/', views.get_logs, name='get_logs'),
    path('add_log/', views.add_log, name='add_log'),
    path('update_log/<int:id>/', views.update_log, name='update_log'),
    path('delete_log/<int:id>/', views.delete_log, name='delete_log'),
    path('get_log/<int:id>/', views.get_log, name='get_log'),  # 获取单个日志

    # 用户管理
    path('get_users/', views.get_users, name='get_users'),
    path('get_user/<int:id>/', views.get_user, name='get_user'),
    path('add_user/', views.add_user, name='add_user'),
    path('update_user/<int:id>/', views.update_user, name='update_user'),
    path('delete_user/<int:id>/', views.delete_user, name='delete_user'),

    # 种植员管理
    path('get_planters/', views.get_planters, name='get_planters'),
    path('add_planter/', views.add_planter, name='add_planter'),
    path('update_planter/<int:id>/', views.update_planter, name='update_planter'),
    path('delete_planter/<int:id>/', views.delete_planter, name='delete_planter'),

    # 检测员管理
    path('get_inspectors/', views.get_inspectors, name='get_inspectors'),
    path('add_inspector/', views.add_inspector, name='add_inspector'),
    path('update_inspector/<int:id>/', views.update_inspector, name='update_inspector'),
    path('delete_inspector/<int:id>/', views.delete_inspector, name='delete_inspector'),
]

